package it.crosato.stage.server.model.retriever;

import static org.junit.Assert.assertTrue;
import java.util.Vector;

import it.crosato.stage.shared.exceptions.NonExistentException;
import it.crosato.stage.shared.exceptions.RetrievingException;
import it.crosato.stage.shared.objects.Pathway;
import it.crosato.stage.shared.objects.Reaction;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class ReactionRetrieverTest {

	@Test
	public void testGetReaction() {
		Reaction reaction = null;
		try {
			Pathway pathway = new PathwayRetriever().getPathway("path:map00020", "hsa", 604800000);
			reaction = new ReactionRetriever().getReaction(pathway.getReaction(0).getId(), pathway.getId(),
					pathway.getEnzymes(), 604800000);
		}
		catch (RetrievingException re) { }
		catch (NonExistentException ne) { }
		assertTrue(reaction != null);
	}

	@Test
	public void testGetPathwayReactions() {
		Vector<Reaction> reactions = null;
		try {
			Pathway pathway = new PathwayRetriever().getPathway("path:map00020", "hsa", 604800000);
			Vector<String> reaStr = new Vector<String>();
			for (int i = 0; i < pathway.getReactions().size(); i++) {
				reaStr.add(pathway.getReaction(i).getId());
			}
			reactions = new ReactionRetriever().getPathwayReactions(pathway.getId(), reaStr,
					pathway.getEnzymes(), 604800000);
		}
		catch (RetrievingException re) { }
		catch (NonExistentException ne) { }
		assertTrue(reactions != null && reactions.size() > 0);
	}
	
	@Before
	public void setUp() {
		
	}
	
	@After
	public void tearDown() {
		
	}

}
